package com.xnsy.jishexiangmu.controller;
import com.xnsy.jishexiangmu.pojo.JuBao;
import com.xnsy.jishexiangmu.pojo.School;
import com.xnsy.jishexiangmu.pojo.SchoolActive;
import com.xnsy.jishexiangmu.service.school.SchoolService;
import com.xnsy.jishexiangmu.uitl.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/school")

public class SchoolController {
    @Autowired
    private SchoolService schoolService;
    @GetMapping("/get")
    public Result get(){
        List<School>  schools = schoolService.get();
        return Result.success(schools);
    }
    // 获取学校全部活动
    @GetMapping("/getall")
    public Result getAll(){
        List<SchoolActive> schoolActives = schoolService.getAll();
        return Result.success(schoolActives);
    }
    // 获取学校单个活动
    @GetMapping("/getone")
    public Result getOne(@RequestParam Integer id){
        SchoolActive schoolActive = schoolService.getOne(id);
        return Result.success(schoolActive);
    }
    @GetMapping("/getbyid")
    public Result getFirst(@RequestParam Integer id){
        School school = schoolService.getById(id);
        return Result.success(school);
    }

    // 根据标题实现模糊查询
    @GetMapping("/getsome")
    public Result getsome(@RequestParam String name){
        List<School> schools = schoolService.getSome(name);
        return Result.success(schools);
    }

}
